package na.learn.java.corepatterns.pooling;

import java.sql.Connection;

public class CommonParams {

	private boolean autoCommit;

	private int transactionIsolation;

	private int initTotalConnections;

	private int minIdle;

	private int maxIdle;

	private int staleAfterTimeMillisecs;

	private int minConnectionsPerHost;

	private int maxConnectionsPerHost;

	private int maxTotalConnections;

	private void setDefaults() {

		autoCommit = true;
		transactionIsolation = Connection.TRANSACTION_NONE;
		initTotalConnections = 5;
		minIdle = 1;
		maxIdle = 1;
		staleAfterTimeMillisecs = 300;
		minConnectionsPerHost = 2;
		maxConnectionsPerHost = 5;
		maxTotalConnections = 25;

	}

	public CommonParams() {
		super();
		setDefaults();
		// TODO Auto-generated constructor stub
	}

	public CommonParams(int initTotalConnections, int maxTotalConnections) {
		setDefaults();
		this.initTotalConnections = initTotalConnections;
		this.maxTotalConnections = maxTotalConnections;
	}

	public boolean isAutoCommit() {
		return autoCommit;
	}

	public void setAutoCommit(boolean autoCommit) {
		this.autoCommit = autoCommit;
	}

	public int getMaxIdle() {
		return maxIdle;
	}

	public void setMaxIdle(int maxIdle) {
		this.maxIdle = maxIdle;
	}

	public int getMinIdle() {
		return minIdle;
	}

	public void setMinIdle(int minIdle) {
		this.minIdle = minIdle;
	}

	public int getStaleAfterTimeMillisecs() {
		return staleAfterTimeMillisecs;
	}

	public void setStaleAfterTimeMillisecs(int staleAfterTimeMillisecs) {
		this.staleAfterTimeMillisecs = staleAfterTimeMillisecs;
	}

	public int getTransactionIsolation() {
		return transactionIsolation;
	}

	public void setTransactionIsolation(int transactionIsolation) {
		this.transactionIsolation = transactionIsolation;
	}

	public int getMaxConnectionsPerHost() {
		return maxConnectionsPerHost;
	}

	public void setMaxConnectionsPerHost(int maxConnectionsPerHost) {
		this.maxConnectionsPerHost = maxConnectionsPerHost;
	}

	public int getMaxTotalConnections() {
		return maxTotalConnections;
	}

	public void setMaxTotalConnections(int maxTotalConnections) {
		this.maxTotalConnections = maxTotalConnections;
	}

	public int getInitTotalConnections() {
		return initTotalConnections;
	}

	public void setInitTotalConnections(int initTotalConnections) {
		this.initTotalConnections = initTotalConnections;
	}

	public int getMinConnectionsPerHost() {
		return minConnectionsPerHost;
	}

	public void setMinConnectionsPerHost(int minConnectionsPerHost) {
		this.minConnectionsPerHost = minConnectionsPerHost;
	}

}
